// 
// $Rev:: 21            $:  Revision of last commit
// $Author:: rvhaverm@g#$:  Author of last commit
// $Date:: 2010-07-25 1#$:  Date of last commit
// 
package agents.hosts;

import com.ibm.aglet.AgletContext;
import com.ibm.aglet.system.AgletRuntime;

import agents.configuration.HostConfigurationFile;
import agents.configuration.IHostConfiguration;
import agents.core.Components;
import agents.interfaces.IAgentHost;
import agents.interfaces.IAgentHostFactory;
import agents.interfaces.IHostEventListener;
import agents.interfaces.ILogger;
import agents.listeners.ConsoleAgentEventListener;
import agents.listeners.ConsoleHostEventListener;
import agents.logging.ConsoleLogger;


public class HostBillBoardService extends BaseAgentHost
{

    public HostBillBoardService(IHostConfiguration props, AgletRuntime runtime,
	    AgletContext context, ILogger logger)
    {
	super(props, runtime, context, logger);
    }
    
    public void start()
    {
	super.start();
	
	// TODO: activate some services at startup
	// GraphicsRepositoryAgent
	// ItineraryAdvisor ...
    }

    public static void main(String[] args)
    {
	Components.Instance().setLogger(new ConsoleLogger());
	Components.Instance().getAgentEventListeners().add(new ConsoleAgentEventListener());
	Components.Instance().getHostEventListeners().add(new ConsoleHostEventListener());

	// Load the properties file into a HostProperties-object.
	IHostConfiguration props = new HostConfigurationFile(args[0]);

	// Create a host
	IAgentHostFactory factory = new AgentHostFactory();
	IAgentHost hostApp = factory.createHostBillBoardService(props);
	Components.Instance().setAgentHost(hostApp);
	
	for (IHostEventListener listener : Components.Instance()
		.getHostEventListeners())
	{
	    hostApp.addHostListener(listener);
	}

	// Initialize the host
	hostApp.start();
    }

}
